/**
 * 通过connect创建一个net.socket客户端
 */
var net = require('net');

var client = net.connect({port: 8124},function(){
    console.log('client connected');
    client.write("客户端发出数据");
});


client.on('data',function(data){
    console.log("接收到： " + data.toString());   //二进制转字符串
    client.end();
})


client.on('end',function(){
    console.log('client disconnected');
})

/**
 
 //第一次
var net = require('net');
var client = net.connect({port: 8124},function(){
    console.log('client connected');
    client.write("world!\r\n");
});
client.on('data',function(data){
    console.log(data.toString());   //二进制转字符串
    client.end();
})
client.on('end',function(){
    console.log('client disconnected');
})
*/

